<template>
	<view class="page" :style="{ 'height': (h + (list.length > 0 ? 0 : 90 - mt)) + 'px', 'padding-top': mt + 'px' }">
		<c-nav-bar title="车辆管理" backUrl="/pages/my/index"></c-nav-bar>
		<view class="add">
			<view @tap="addLicence">
				<image src="https://i.ringzle.com/file/20240227/a4282045f8de4367b05ed8da86cea8e6.png"></image>
				<text>添加</text>
			</view>
		</view>
		<view class="title">车辆列表</view>
		<view class="list" v-if="list.length > 0">
			<view v-for="(item, index) in list" :key="index">
				<view class="l_left">
					<view class="ll_r">
						<image src="https://i.ringzle.com/file/20240227/ea300d9a5fa243bf8c66ad0327f79bc4.png"></image>
						<view class="llr_r">
							<text>{{ item.numberplate }}</text>
							<text class="lr_default" v-if="item.type === 1">默认</text>
						</view>
					</view>
				</view>
				<view class="l_right" @tap.stop="editLicence(item)">
					<image src="https://i.ringzle.com/file/20240227/e66ffdab3ea149bda76681fb92615a20.png"></image>
				</view>
			</view>
		</view>
		<view class="empty" :style="{ 'height': (h - mt - 102) + 'px' }" v-else>
			<!-- <image src="https://i.ringzle.com/file/20231115/91b076eb140945f58a5d87f5becbd198.png"></image> -->
			<image class="no_img" src="https://i.ringzle.com/file/20240104/a41e61c5857c446c8f6c63aa12008681.png">
			</image>
			<text>暂无数据</text>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			h: uni.getSystemInfoSync().windowHeight,
			mt: uni.getSystemInfoSync().statusBarHeight + 44,
			titleStyle: {
				fontSize: '36rpx',
				fontWeight: "bold",
				color: "#333333"
			},
			licence: '',
			list: []
		}
	},
	onShow() {
		this.getList();
	},
	methods: {
		getList() {
			this.$api.get('/travel/wisdom/BindingNumberplate/find?openId=' + JSON.parse(uni.getStorageSync('userInfo')).openId).then(res => {
				if (res.data.code === 0) {
					this.list = res.data.data;
				} else this.$showModal(res.data.msg);
			})
		},
		addLicence() {
			uni.navigateTo({
				url: '/pagesIndex/parkingService/licenceOperation?type=车辆'
			})
		},
		editLicence(item) {
			uni.navigateTo({
				url: '/pagesIndex/parkingService/licenceOperation?type=车辆&object=' + JSON.stringify({
					licence: item.numberplate,
					id: item.id,
					type: item.type
				})
			})
		}
	}
}
</script>

<style scoped lang="less">
.page {
	background: #F5F8FA;

	.no_img {
		width: 220rpx;
		height: 150rpx;
	}

	.add {
		width: 100%;
		padding: 40rpx 30rpx 30rpx;
		background: transparent;
		box-sizing: border-box;

		&>view {
			width: 100%;
			height: 88rpx;
			background: #F0F8F6;
			border-radius: 12rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			border: 2rpx dotted #007A69;

			image {
				width: 32rpx;
				height: 32rpx;
			}

			text {
				font-size: 32rpx;
				font-family: PingFang SC-Regular, PingFang SC;
				font-weight: 400;
				color: #007A69;
				margin-left: 16rpx;
			}
		}
	}

	.title {
		width: 100%;
		padding: 0 24rpx;
		box-sizing: border-box;
		font-size: 32rpx;
		font-family: PingFang SC-Bold, PingFang SC;
		font-weight: bold;
		color: #333333;
	}

	.list {
		width: 100%;
		padding: 0 24rpx 20rpx;
		box-sizing: border-box;

		&>view {
			margin-top: 20rpx;
			background: #FFFFFF;
			border-radius: 20rpx;
			padding: 40rpx 30rpx;
			width: 100%;
			box-sizing: border-box;
			display: flex;
			align-items: center;
			justify-content: space-between;

			.l_left {
				display: flex;
				align-items: center;

				.ll_r {
					display: flex;

					&>image {
						width: 90rpx;
						height: 90rpx;
					}

					.llr_r {
						display: flex;
						flex-direction: column;
						padding-left: 30rpx;

						text {
							font-size: 40rpx;
							font-family: PingFang SC-Regular, PingFang SC;
							font-weight: bold;
							color: #333333;

							&.lr_default {
								font-size: 26rpx;
								color: #007A69;
								margin-top: 4rpx;
							}
						}
					}
				}
			}

			.l_right {
				image {
					width: 36rpx;
					height: 36rpx;
				}
			}
		}
	}

	.empty {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;

		// image {
		// 	width: 104rpx;
		// 	height: 104rpx;
		// }

		text {
			font-size: 32rpx;
			font-family: PingFang SC-Medium, PingFang SC;
			font-weight: 500;
			color: #333333;
			margin-top: 17rpx;
		}
	}
}
</style>